package com.lsr.community.com.lsr.community.com.lsr.communirty.cofig;

import com.lsr.community.com.lsr.community.handler.UserHandler;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Auther :lishuren
 * @Date : 2021/11/8
 * @Description: com.lsr.community.com.lsr.community.com.lsr.communirty.cofig
 * @Version :1.0
 **/

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

//        定义需要拦截的路径
        String[] addPathPatterns ={
          "/user/**"
        };

//定义不需要拦截的路径
        String[] excluedPathPatterns ={
                "/user/list",
                "/user/error"
        };

        registry.addInterceptor(new UserHandler()) //添加要注册的拦截器对象
                .addPathPatterns()  //添加需要拦截的路径
                .excludePathPatterns(excluedPathPatterns);  //添加不需要拦截的路径

    }
}
